{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" onsubmit="return false" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="driver_id" value="{$driver_id}">
        <table class="table table-border table-bordered table-hover table-bg mt-20">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox"></th>
                <th width="">id</th>
                <th width="">标签名</th>
            </tr>
            </thead>
            <?php if(!$driverRankTag){ $driverRankTag = [];} ?>
            <tbody>
            {volist name="$driverDrank" id="driver_rank"}
            <tr class="text-c">
                <td><input type="checkbox" name="id[]" {if in_array($driver_rank['id'],$driverRankTag)}checked{/if} value="{$driver_rank.id}"></td>
                <td>{$driver_rank.id}</td>
                <td>{$driver_rank.chinese}</td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" id="submit" class="btn btn-primary radius" onclick="add_tag()">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<!--时间插件-->
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/template/template.js"></script>
<script>
    function add_tag() {
        // var index = parent.layer.getFrameIndex(window.name)
        $.ajax({
            type: "POST",
            url: '/admin/driver/add_tag',
            data: $('#form').serialize(),
            success: function (result) {
                if (result.code){
                    layer.msg(result.msg)
                } else{
                    layer.msg(result.msg)
                    parent.location.reload()
                    layer.close()
                }
            },
            error: function () {
                layer.msg('错误')
            }
        })
    }
</script>
{/block}
